﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace ZhimeiSoft.CharmManager.DOL
{

    /// <summary>
    /// 店信息表
    /// </summary>
    [Serializable()]
    public class DBEntitySalonInfo : DBEntityBase
    {
        /// <summary>
        /// 表名称
        /// </summary>
        /// <returns>返回表名称</returns>
        public override string GetTableName()
        {
            return "SALONINFO";
        }

        public DBEntitySalonInfo()
            : base()
        {
        }

        public DBEntitySalonInfo(DataRow drRow)
        {
            this.SALONID = Convert.ToInt32(drRow[DBEntitySalonInfo.FieldName.SALONID]);
            this.SNAME = drRow[DBEntitySalonInfo.FieldName.SNAME].ToString();
            this.SZIPCODE = drRow[DBEntitySalonInfo.FieldName.SZIPCODE].ToString();
            this.SADDRESS = drRow[DBEntitySalonInfo.FieldName.SADDRESS].ToString();
            this.SPHONE1 = drRow[DBEntitySalonInfo.FieldName.SPHONE1].ToString();
            this.SPHONE2 = drRow[DBEntitySalonInfo.FieldName.SPHONE2].ToString();
            this.SFAX1 = drRow[DBEntitySalonInfo.FieldName.SFAX1].ToString();
            this.SFAX2 = drRow[DBEntitySalonInfo.FieldName.SFAX2].ToString();
            this.SCONTACTPERSON1 = drRow[DBEntitySalonInfo.FieldName.SCONTACTPERSON1].ToString();
            this.SCONTACTPERSON2 = drRow[DBEntitySalonInfo.FieldName.SCONTACTPERSON2].ToString();
            this.SOPENTIME = drRow[DBEntitySalonInfo.FieldName.SOPENTIME].ToString();
            this.SENDTIME = drRow[DBEntitySalonInfo.FieldName.SENDTIME].ToString();
            this.SMEMO = drRow[DBEntitySalonInfo.FieldName.SMEMO].ToString();
        }
        /// <summary>
        /// 店的ID
        /// </summary>
        public int SALONID { get; set; }
        /// <summary>
        /// 店名称
        /// </summary>
        public string SNAME { get; set; }
        /// <summary>
        /// 店邮政编码
        /// </summary>
        public string SZIPCODE { get; set; }
        /// <summary>
        /// 店地址
        /// </summary>
        public string SADDRESS { get; set; }
        /// <summary>
        /// 联系电话1
        /// </summary>
        public string SPHONE1 { get; set; }
        /// <summary>
        /// 联系电话2
        /// </summary>
        public string SPHONE2 { get; set; }
        /// <summary>
        /// 传真1
        /// </summary>
        public string SFAX1 { get; set; }
        /// <summary>
        /// 传真2
        /// </summary>
        public string SFAX2 { get; set; }
        /// <summary>
        /// 联系人1
        /// </summary>
        public string SCONTACTPERSON1 { get; set; }
        /// <summary>
        /// 联系人2
        /// </summary>
        public string SCONTACTPERSON2 { get; set; }
        /// <summary>
        /// 上班时间
        /// </summary>
        public string SOPENTIME { get; set; }
        /// <summary>
        /// 下班时间
        /// </summary>
        public string SENDTIME { get; set; }
        /// <summary>
        /// 备注信息
        /// </summary>
        public string SMEMO { get; set; }
        /// <summary>
        /// 字段名
        /// </summary>
        public static class FieldName
        {
            /// <summary>
            /// 店的ID
            /// </summary>
            public const string SALONID = "SALONID";
            /// <summary>
            /// 店名称
            /// </summary>
            public const string SNAME = "SNAME";
            /// <summary>
            /// 店邮政编码
            /// </summary>
            public const string SZIPCODE = "SZIPCODE";
            /// <summary>
            /// 店地址
            /// </summary>
            public const string SADDRESS = "SADDRESS";
            /// <summary>
            /// 联系电话1
            /// </summary>
            public const string SPHONE1 = "SPHONE1";
            /// <summary>
            /// 联系电话2
            /// </summary>
            public const string SPHONE2 = "SPHONE2";
            /// <summary>
            /// 传真1
            /// </summary>
            public const string SFAX1 = "SFAX1";
            /// <summary>
            /// 传真2
            /// </summary>
            public const string SFAX2 = "SFAX2";
            /// <summary>
            /// 联系人1
            /// </summary>
            public const string SCONTACTPERSON1 = "SCONTACTPERSON1";
            /// <summary>
            /// 联系人2
            /// </summary>
            public const string SCONTACTPERSON2 = "SCONTACTPERSON2";
            /// <summary>
            /// 上班时间
            /// </summary>
            public const string SOPENTIME = "SOPENTIME";
            /// <summary>
            /// 下班时间
            /// </summary>
            public const string SENDTIME = "SENDTIME";
            /// <summary>
            /// 备注信息
            /// </summary>
            public const string SMEMO = "SMEMO";
        }
        /// <summary>
        /// 根据店名获取店ID
        /// </summary>
        /// <param name="dtSalonInfo">传入的店信息</param>
        /// <param name="salonName">店名称</param>
        /// <param name="salonID">返回店ID</param>
        /// <param name="error">错误信息</param>
        /// <returns>返回是否成功</returns>
        public static bool getSalonNameForSalonID(DataTable dtSalonInfo, string salonName, out int salonID, out string error)
        {
            error = string.Empty;
            salonID = -1;
            string filter = string.Concat(DBEntitySalonInfo.FieldName.SNAME, " = '", salonName.ToString(), "'");
            DataRow[] drSerch = dtSalonInfo.Select(filter , "", DataViewRowState.CurrentRows);
            if (drSerch.Length == 0)
            {
                error = "未能找到相关店的信息";
                return false;
            }
            salonID = Convert.ToInt32(drSerch[0][DBEntitySalonInfo.FieldName.SALONID]);
            return true;

        }
        /// <summary>
        /// 根据店ID获取店名
        /// </summary>
        /// <param name="dtSalonInfo">传入的店信息</param>
        /// <param name="salonID">店ID</param>
        /// <param name="salonName">返回店名</param>
        /// <param name="error">错误信息</param>
        /// <returns>返回是否成功</returns>
        public static bool getSaloinIDForSalonName(DataTable dtSalonInfo, int salonID, out string salonName, out string error)
        {
            error = string.Empty;
            salonName = string.Empty;
            string filter = string.Concat(DBEntitySalonInfo.FieldName.SALONID, " = ", salonID);
            DataRow[] drSerch = dtSalonInfo.Select(filter, "", DataViewRowState.CurrentRows);
            if (drSerch.Length == 0)
            {
                error = "未能找到相关店的信息";
                return false;
            }
            salonName = drSerch[0][DBEntitySalonInfo.FieldName.SNAME].ToString();
            return true;
        }

        

    }

}
